package com.htjx.mall.services;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
import org.springframework.transaction.support.TransactionTemplate;

import com.htjx.mall.commons.mappers.AdminMapper;
import com.htjx.mall.commons.models.Admin;

@Service
public class AdminService {
	@Autowired
	private AdminMapper adminMapper;
	@Autowired
	private TransactionTemplate transactionTemplate;
	
	public Admin SelectByAdminName(String adminName) {
		return adminMapper.selectByAdminName(adminName);
	}
	
	public void updateOne(final Admin admin) {
		transactionTemplate.execute(new TransactionCallbackWithoutResult() {
			@Override
			protected void doInTransactionWithoutResult(TransactionStatus status) {
				adminMapper.updateOne(admin);
			}
		});
	}
}
